package cn.edu.scau.cmi.zengdefeng.Adapter;

import java.util.List;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Controller {
	@FXML
	private TextArea result;
	@FXML
	private Button caNext;
	@FXML
	private Button caFinish;
	@FXML
	private Button oaNext;
	@FXML
	private Button oaFinish;
	@FXML
	private TextField oaID;
	@FXML
	private TextField oaName;
	@FXML
	private TextField caID;
	@FXML
	private TextField caName;

	private ClassAdapter ca = new ClassAdapter();
	private ObjectAdapter oa = new ObjectAdapter();

	@FXML
	public void caAddStudent() {

		ca.addStudent(caName.getText(), Integer.parseInt(caID.getText()));
	}

	@FXML
	public void caFinish() {
		ca.addStudent(caName.getText(), Integer.parseInt(caID.getText()));
		List<Student> studentList = ca.getStudentList();
		for (int i = 0; i < studentList.size(); i++) {
			result.appendText("学号：" + studentList.get(i).getID() + "	姓名：" + studentList.get(i).getName() + "\n");
		}
	}

	@FXML
	public void oaAddStudent() {

		oa.addStudent(oaName.getText(), Integer.parseInt(oaID.getText()));
	}

	@FXML
	public void oaFinish() {
		oa.addStudent(oaName.getText(), Integer.parseInt(oaID.getText()));
		List<Student> studentList = oa.getStudentList();
		for (int i = 0; i < studentList.size(); i++) {
			result.appendText("学号：" + studentList.get(i).getID() + "	姓名：" + studentList.get(i).getName() + "\n");
		}
	}

}
